﻿public abstract class Skill : ISkill
{
	public bool IsActive { get; set ; }
	public SkillAttribute SkillAtr { get; protected set; }  

	protected SkillLogic Logic { get; set; }
	protected float ChargeTime { get; set; }
	virtual public void Execute(RoleCtrl role)
	{
		if (!this.IsActive)
			return;
		IsActive = false; 
		switch (this.SkillAtr.Type)
		{
			case SkillAttribute.SkillType.Place:
				ExecutePlace();
				break;

			case SkillAttribute.SkillType.Property:
				ExecuteProperty();
				break;
		}
		if (!this.SkillAtr.IsDisposable)
		{
			//重新充能
			ChargeTime = SkillAtr.RechargeTime;
			Logic.AddChargeSkill(this);
		}
		else
		{
			//移出Skill
			//TODO	Logic.RemoveSkill();
			role.RemoveSkill(this);
		}
	}

	public void DoCharge(float deltaTime)
	{
		ChargeTime -= deltaTime;
		if (ChargeTime <= 0)
			IsActive = true;
	}

	public Skill(SkillLogic logic, SkillAttribute attribute)
	{
		this.Logic = logic;
		Init(attribute);
	}
	public void Init(SkillAttribute attribute)
	{
		this.SkillAtr = attribute;
	}

	protected abstract void ExecuteProperty();
	protected abstract void ExecutePlace();
}
